#!/bin/bash

# 测试PROJECT_ENV_CONFIG功能的脚本

echo "=== PROJECT_ENV_CONFIG功能测试 ==="
echo

# 测试1: 验证环境变量脚本可以正常执行
echo "测试1: 验证环境变量脚本执行"
source ./project_env_test.sh
echo "✅ 环境变量脚本执行成功"
echo

# 测试2: 验证构建时环境变量加载
echo "测试2: 验证构建时环境变量加载"
echo "构建时设置的环境变量:"
echo "  PROJECT_NAME=$PROJECT_NAME"
echo "  PROJECT_VERSION=$PROJECT_VERSION"
echo "  BUILD_TYPE=$BUILD_TYPE"
echo "  CUSTOM_COMPILER_FLAGS=$CUSTOM_COMPILER_FLAGS"
echo "  PROJECT_AUTHOR=$PROJECT_AUTHOR"
echo "  ENABLE_TESTS=$ENABLE_TESTS"
echo

# 测试3: 验证运行时环境变量传递
echo "测试3: 验证运行时环境变量传递"
echo "运行测试程序（传递环境变量）:"
PROJECT_NAME="$PROJECT_NAME" PROJECT_VERSION="$PROJECT_VERSION" BUILD_TYPE="$BUILD_TYPE" CUSTOM_COMPILER_FLAGS="$CUSTOM_COMPILER_FLAGS" PROJECT_AUTHOR="$PROJECT_AUTHOR" ENABLE_TESTS="$ENABLE_TESTS" ../../out/release/build_env_test

if [ $? -eq 0 ]; then
    echo "✅ PROJECT_ENV_CONFIG功能测试全部通过！"
else
    echo "❌ 测试失败"
    exit 1
fi